package com.mornd.gulimall.member.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.mornd.gulimall.common.core.result.AjaxResult;
import com.mornd.gulimall.member.entity.MemberReceiveAddress;
import com.mornd.gulimall.member.service.IMemberReceiveAddressService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 会员收货地址 前端控制器
 * </p>
 *
 * @author mornd
 * @since 2023-07-31
 */
@RestController
@RequestMapping("/member/memberReceiveAddress")
public class MemberReceiveAddressController {
    @Resource
    private IMemberReceiveAddressService service;

    @GetMapping("/getByMemberId/{memberId}")
    public AjaxResult getByMemberId(@PathVariable Long memberId) {
        List<MemberReceiveAddress> list = service.list(Wrappers.<MemberReceiveAddress>lambdaQuery().eq(MemberReceiveAddress::getMemberId, memberId));
        return AjaxResult.success(list);
    }

    @GetMapping("/getById/{id}")
    public AjaxResult getById(@PathVariable Long id) {
        MemberReceiveAddress address = service.getById(id);
        return AjaxResult.success(address);
    }

}
